package de.fuberlin.dbs.wm.service;

import java.sql.SQLException;

import de.fuberlin.dbs.wm.dao.PlayerDao;
import de.fuberlin.dbs.wm.dao.TeamDao;
import de.fuberlin.dbs.wm.dao.model.Player;
import de.fuberlin.dbs.wm.dao.model.Team;

public class PlayerService {
	
	public PlayerService() {
	}
	
	/**
	 * @return Team of player with given id, null if an error occurred
	 */
	public Team getTeamOfPlayer(int id) {
		Team team;
		Player player;
		try {
			player = PlayerDao.getPlayerById(id);
			team = TeamDao.getTeamByName(player.getTeamName());
		} catch (SQLException e) {
			return null;
		}
		return team;
	}
}
